package com.yonyou.crm.base.attr.rmimpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yonyou.crm.base.attr.entity.AttrBVO;
import com.yonyou.crm.base.attr.entity.AttrVO;
import com.yonyou.crm.base.attr.rmitf.IAttrRmService;
import com.yonyou.crm.base.attr.service.AttrBBizServiceImpl;
import com.yonyou.crm.base.attr.service.AttrBizServiceImpl;
import com.yonyou.crm.common.page.entity.Page;

@Service("attrService")
public class AttrRmServiceImpl implements IAttrRmService {

	@Autowired
	private AttrBizServiceImpl service;
	
	@Autowired
	private AttrBBizServiceImpl bservice;
	
	@Override
	public Page<AttrVO> page(Page<AttrVO> page, Map<String, Object> paraMap) {
		return service.getPage(page, paraMap);
	}

	@Override
	public AttrVO detail(Long id) {
		return service.getVOById(AttrVO.class, id);
	}

	@Override
	public AttrVO insert(AttrVO vo) {
		service.saveVO(vo);
		return service.getPageDetail(vo.getId());
	}

	@Override
	public AttrVO update(AttrVO vo) {
		service.updateVO(vo);
		return service.getPageDetail(vo.getId());
	}

	@Override
	public String batchDelete(String[] ids) {
		return service.batchDeleteByIDs(AttrVO.class, ids);
	}

	@Override
	public Page<AttrVO> batchUpdateEnableState(String[] ids,
			Integer enableState, Page<AttrVO> page, Map<String, Object> paraMap) {
		service.batchUpdateEnableState(ids, enableState);
		return service.getPage(page, paraMap);
	}
	
	@Override
	public List<AttrVO> getAttrRefList() {
		return service.getRefList();
	}

	@Override
	public List<AttrBVO> getAttrValueRefList(Long attrId) {
		return bservice.getRefList(attrId);
	}
	
	@Override
	public boolean isCitedByAttrGroup(Long valueId) {
		return bservice.isCitedByAttrGroup(valueId);
	}
	
	@Override
	public List<String> getIdsByAttrGroup(Long attrId) {
		return bservice.getIdsByAttrGroup(attrId);
	}
	
}
